package com.globallogic.dailyplanner.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.globallogic.dailyplanner.dto.Mail;
import com.globallogic.dailyplanner.repository.MailRepository;
import com.globallogic.dailyplanner.service.MailService;

@Service
public class MailServiceImpl implements MailService {

	@Autowired
	MailRepository mailRepository;
	
	@Override
	@Transactional(propagation=Propagation.NOT_SUPPORTED)
	public Mail getById(int id) {
		return mailRepository.getOne(id);
	}

	@Override
	@Transactional(propagation=Propagation.REQUIRES_NEW, timeout=30)
	public Mail save(Mail mail) {
		return mailRepository.saveAndFlush(mail);
	}

}
